#coding=utf-8

s = '{name} has {n} message.'
s.format(name='Guido', n=37)
print(s)

name = 'Guido'
n = 37
# s.format_map(vars())

class Info:
    def __init__(self, name, n):
        self.name = name
        self.n = n
a = Info('Guido', 37)
# s.format_map(vars(a))

class safesub(dict):
    def __missing__(self, key):
        return '{' + key + '}'

import sys
def sub(text):
    return text.format_map(safesub(sys._getframe(1).f_locals))